// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'

import http from './util/http.js'

import 'babel-polyfill'
import iView from 'iview'
import 'iview/dist/styles/iview.css';    // 使用 CSS

import 'bootstrap/dist/css/bootstrap.min.css';    // 使用 bootstrap


import echarts from 'echarts'  // 图表

Vue.use(iView);

router.beforeEach((to, from, next) => {
  let name = localStorage.getItem('adminName')
  let password = localStorage.getItem('adminPassword')
  if (to.meta.adminAuth) {
    if (!name || !password) {
      next('/login')
    } else {
      next()
    }
  } else {
    next()
  }
})

Vue.prototype.http = http
Vue.prototype.$echarts = echarts

Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  template: '<App/>',
  components: { App }
})
